﻿namespace Armon.Lib.Extensions.Collections
{
    public static class EnumerableExtension
    {
        public static bool IsNullOrEmpty<T>(this IEnumerable<T> values)
        {
            return values is null || !values.Any();
        }

        public static bool AnyNullOrWhiteSpace(this IEnumerable<string> values)
        {
            return values.Any(string.IsNullOrWhiteSpace);
        }

        public static bool AllNullOrWhiteSpace(this IEnumerable<string> values)
        {
            return values.All(string.IsNullOrWhiteSpace);
        }

        public static string ToString(this IEnumerable<string> s, char? separator = null)
        {
            if (separator is null)
            {
                return string.Join("", s);
            }

            return string.Join(separator.Value, s);
        }
    }
}